//
//  BaseListViewController.m
//  SleepingElf
//
//  Created by karong on 2023/6/6.
//

#import "BaseListViewController.h"

@interface BaseListViewController ()

@property (nonatomic, assign) BOOL showLoading;   // 是否展示的是加載頁面
@property (nonatomic, assign) BOOL firstLoadPage; // 是否是首次加載頁面，防止一进入頁面就顯示空狀態

@property (nonatomic, strong) MJRefreshGifHeader *mj_header;
// 重试
@property (assign, nonatomic) BOOL retryRefresh;

@end

@implementation BaseListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.firstLoadPage = YES;
    self.listView.showsHorizontalScrollIndicator = NO;
    self.listView.showsVerticalScrollIndicator = NO;
    // 刷新動画
    self.mj_header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData)];
    self.mj_header.lastUpdatedTimeLabel.hidden = YES;
    self.listView.mj_header = self.mj_header;
    if (self.disableAutoBeginRefresh) {
        [self.listView.mj_header beginRefreshing];
    }
    if ([self.listView isKindOfClass:[UITableView class]]) {
        UITableView *tableView = (UITableView *)self.listView;
        if (tableView.style == UITableViewStylePlain) {
            tableView.tableFooterView = [[UIView alloc] init];
        }
    }
}

#pragma mark -

- (void)listViewBeginRefresh
{
    [self.listView.mj_header beginRefreshing];
}

- (void)listViewEndRefresh
{
    [self.listView.mj_header endRefreshing];
}

- (void)refreshData
{
    
}

- (BOOL)disableAutoBeginRefresh
{
    return NO;
}
#pragma mark -

- (UIScrollView *)listView
{
    return nil;
}


@end
